-
Notifications
You must be signed in to change notification settings - Fork 1
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: introduce useSocial
and useSocialProfile
hooks
#22
base: beta
Are you sure you want to change the base?
feat: introduce useSocial
and useSocialProfile
hooks
#22
Conversation
7316c27
to
b311f57
Compare
Hey @shelegdmitriy, thanks for the pull request! I'm glad to hear we can join forces on this SDK, maybe we can start a chat or schedule a call sometime to fully understand all your requirements and how you plan to use it. Also -- we discuss this project in the Build DAO telegram chat, under "NearSocialJS" topic, feel free to join! Regarding the pull request -- my first feeling is that we should keep any react-specific hooks and components separate from the core package -- we can make this a monorepo and split this into several packages, for this: @near-social-js/react Although I also don't want to slow down any progress -- I would be fine with merging this now into the v1 release with the understanding that this will change, but I think this will introduce more headaches on both sides if it's not implemented 100% as we want it. With that said, we're about to release v1 this week, and I think I'd recommend keeping these hooks and provider in your own app and reference v1 methods, until we feel confident + stable to move these into this package. What do you think @kieranroneill @jaswinder6991 ? |
Thanks @elliotBraem for sharing your thoughts. That being said, we are also figuring out a lot of things about the library at the moment. Probably in the future we would have a clearer picture if we need anything like this. @shelegdmitriy we look forward to talking to you and understand what are your requirements and needs for social-db-sdk, we can indeed reduce duplicated efforts. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
First off, nice work @shelegdmitriy!
As @elliotBraem suggested, I think splitting this into a monorepo would be a good idea. The "core" work that is already in here is agnostic any JS environment and adding in React would cause issues for those that want to use this outside of React.
We are imminently about to push v1 release, and I think the first priority will be setup a monorepo and use your contribution as the React repo. As @elliotBraem mentioned, I like the @builddao/near-social-js/react
package.
|
||
const { social } = result.current; | ||
|
||
let data: any; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this will fail the linter. For objects, we can use Record<string, unknown>
.
useSocial: jest.fn(() => ({ | ||
social: { | ||
async get({ keys }: { keys: string[] }) { | ||
return keys.reduce((acc, key) => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
.reduce
allows you to declare the the type to cast, rather than using the as
notation.
keys.reduce<Record<string, unknown>>((acc, key) => {
acc[key] = { profile: { name: 'TestUser' } };
return acc;
}, {});
async getVersion() { | ||
return '1.0.0'; | ||
}, | ||
async set({ data }: { data: Record<string, any> }) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As before, Record<string, unknown>
is favoured over using any
.
@kieranroneill @jaswinder6991 @elliotBraem thank you all for your feedback! I agree with everything that you described here.
I like this solution and happy to improve this PR according to your suggestions. What is the next steps for me with this PR? Should I just close this one and re-open it in a monorepo? Do you want me to improve it with your suggestions and leave it here instead without closing? |
Description
This PR includes the following hooks for convenience:
useSocial()
for easily accessing the Social SDK instance shared by the provider.useSocialProfile()
for easily accessing any account ID's social profile.Context
Some time ago, something similar to this sdk has been created here and recently that module was ported as a separate repo here.
near-social-js
has almost the same functionality (maybe even more) as near-social-db-sdk. That's why I decided to contribute to your module (and maybe collaborate in a future) to avoid duplicate modules.Also, feel free to check out near-social-db-sdk on your own and leave your thoughts on what would you like to port to this module too
Type of change